package org.example.util;

import com.alibaba.fastjson2.JSON;
import jakarta.servlet.http.HttpServletResponse;
import org.example.entity.ResponseModel;

import java.io.IOException;
import java.io.PrintWriter;

public class ResponseUtil {
    public static void printData(HttpServletResponse response, ResponseModel rm) {
        response.setContentType("application/json;charset=utf-8");

        PrintWriter writer = null;
        try {
            writer = response.getWriter();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        writer.write(JSON.toJSONString(rm));
    }

}
